{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pylab as plt\n",
    "import datetime\n",
    "\n",
    "from sklearn.preprocessing import LabelBinarizer\n",
    "from sklearn.utils import shuffle\n",
    "from collections import Counter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.models import Model\n",
    "from keras.layers import Dense, Dropout, GlobalAveragePooling1D, GaussianNoise, Conv1D, MaxPool1D, GlobalMaxPooling1D\n",
    "from keras.layers import Input, concatenate, SpatialDropout1D, Flatten, AvgPool1D, LSTM, Lambda, Reshape, GaussianDropout\n",
    "from keras.layers import BatchNormalization\n",
    "from keras.callbacks import ModelCheckpoint, EarlyStopping\n",
    "from keras import regularizers\n",
    "from keras.optimizers import RMSprop, Adam, SGD, Nadam\n",
    "import keras.backend as K\n",
    "from keras.regularizers import l1, l2 , l1_l2\n",
    "\n",
    "\n",
    "from sklearn.metrics import confusion_matrix\n",
    "from sklearn.metrics import classification_report, accuracy_score\n",
    "from sklearn.metrics import r2_score\n",
    "from sklearn.metrics import matthews_corrcoef\n",
    "from sklearn.metrics import f1_score"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "tick_bars = pd.read_csv('tick_bars.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "out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J4ys9oZEnvcMjnRZwwX+Gqv0MObzKwO8AZwjXPu59B9FTl+51ye\nc+4QAnfHfYEuaQ4pJmZ2ErDROTcn3bHEqb9zrjdwIjDazAaE7qzAn5ksAt2sTzjnegE7CHTVBFXg\n2OOWyYm+1AXI02yDmbUA8H5v9OqLi7uk+lZR6pPGzKoRSPIvOOf+m2nxAzjntgIfEOiyaGBmBaun\nhV4vGKO3vz6wqZTYU/UZOxI4xczWAC8T6L55KENixzm33vu9EXiTwJdsJnxm1gHrnHMzve3XCST+\nTIg9funuO0qgry2LwAOQdhQ+bOqWxniyCe+jv5/whzt/9crDCH+4M8urb0Sg77Ch97MaaOTtK/pw\nZ2gS4zbgeeAfReorfPxAU6CBV94P+Bg4CXiN8Aeao7zyaMIfaL7qlbsR/kBzFYGHmeXyGQMGUfgw\ntsLHDtQG6oaUPwNOyITPjHfuj4HOXnmsF3dGxB73P3O6A0jwP9hQAqNEvgFuSWMcLwE/AHsJ3DGM\nJNB/Oh34GpgW8iEw4DEv5kVATsh5fgus9H4uCanPARZ7xzxKkQdJCcben8CfqQuB+d7P0EyIHzgY\nmOfFvhi4zas/0PufbSWBxFnDq6/pba/09h8Ycq5bvPhWEDJKojw+Y4Qn+gofuxfjAu9nScG5M+Ez\n4537EGC297n5H4FEnRGxx/ujN2NFRCq5TO6jFxGRGCjRi4hUckr0IiKVnBK9iEglp0QvIlLJKdGL\niFRySvQiIpWcEr2ISCX3/6RNaVnziObMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.plot(tick_bars.close[:int(len(tick_bars) * 0.5)])\n",
    "plt.plot(tick_bars.close[int(len(tick_bars) * 0.5):int(len(tick_bars) * 0.7)])\n",
    "plt.plot(tick_bars.close[int(len(tick_bars) * 0.7):])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Differentiation test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda2/lib/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.\n",
      "  from pandas.core import datetools\n"
     ]
    }
   ],
   "source": [
    "from statsmodels.tsa.stattools import adfuller"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# https://github.com/philipperemy/fractional-differentiation-time-series/blob/master/fracdiff/fracdiff.py\n",
    "\n",
    "def fast_fracdiff(x, d):\n",
    "    import pylab as pl\n",
    "    T = len(x)\n",
    "    np2 = int(2 ** np.ceil(np.log2(2 * T - 1)))\n",
    "    k = np.arange(1, T)\n",
    "    b = (1,) + tuple(np.cumprod((k - d - 1) / k))\n",
    "    z = (0,) * (np2 - T)\n",
    "    z1 = b + z\n",
    "    z2 = tuple(x) + z\n",
    "    dx = pl.ifft(pl.fft(z1) * pl.fft(z2))\n",
    "    return np.real(dx[0:T])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0\n",
      "0.5\n",
      "1.0\n"
     ]
    }
   ],
   "source": [
    "corrs, adfs = [], []\n",
    "\n",
    "for d in np.arange(0.0, 1.5, 0.5):\n",
    "    \n",
    "    print d\n",
    "    \n",
    "    ts1 = np.log(tick_bars.close.values)\n",
    "    ts2 = fast_fracdiff(ts1, d)\n",
    "\n",
    "    corr = np.corrcoef(ts1, ts2)[0,1]\n",
    "    adf = adfuller(ts2)[0]\n",
    "\n",
    "    corrs.append(corr)\n",
    "    adfs.append(adf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "stats = pd.DataFrame({\n",
    "    'd': np.arange(0.0, 1.5, 0.5),\n",
    "    'corr': np.abs(corrs),\n",
    "    'adfs': adfs\n",
    "})\n",
    "stats.index = stats['d']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEKCAYAAAA8QgPpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xd4VGXax/HvnUYghAQIPSAoAWkh\ntNAUUFSKixSlKR1BdLEryy6+K3Z0ragrIAQMKNWyiAoKgoC0hF6kqxA6AUIgpD/vH2fAoJA6yZnJ\n3J/rykVmzpkz9wmE35zzNDHGoJRSSuWVl90FKKWUck8aIEoppfJFA0QppVS+aIAopZTKFw0QpZRS\n+aIBopRSKl80QJRSSuWLBohSSql80QBRSqliREQ6i8geEdkvImML9b3sGonu5eVlSpYsact7K6WU\nu0pKSjLGmGt++BcRb2AvcCcQB8QA/Y0xuwqjFp/COGhulCxZkosXL9r19kop5ZZE5FI2myOB/caY\ng4595wDdgUIJEL2FpZRS7sVHRGKzfI3Msq0acDjL4zjHc4VTSGEdWCmlVKFIN8Y0t7sI0CsQpZQq\nTo4A1bM8DnU8Vyj0CkQplWtpaWnExcWRnJxsdynFnr+/P6Ghofj6+ublZTFAmIjUwgqOfsD9hVEf\naIAopfIgLi6OwMBAatasiYjYXU6xZYwhPj6euLg4atWqlZfXpYvIaGAJ4A1EGWN2FladOd7CEpEo\nETkpIjuus11EZKKjz/E2EWnq/DKVUq4gOTmZ8uXLa3gUMhGhfPny+brSM8Z8a4ypY4y5yRjzSiGU\nd0Vu2kBmAJ2z2d4FCHN8jQQ+KnhZSilXpeFRNNzh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JKx2nq7AfiAJGGpPpfmnI9GV\nUkrliyvfwlJKKeXCNECUUkrliwaIUkqpfNEAUUoplS8aIEoppfJFA0Sp6xCR8SLyjN11KOWqNECU\nUkrliwaIUlmIyDgR2Ssiq4G6dtejlCtz2ZHoShU1EWmGNZtBBNbvxiZgo61FKeXCNECU+sOtwJeX\n11sRkWI3jYpSzqS3sJRSSuWLBohSf1gJ9BCRkiISCHSzuyClXJnewlLKwRizSUTmYq3XfRJrCnKl\n1HXobLxKKaXyRW9hKaWUyhcNEKWUUvmiAaKUUipfNECUUkrliwaIUkqpfNEAUUoplS8aIEoppfJF\nA0QppVS+/D8XrjShWERchQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stats[['corr', 'adfs']].plot(secondary_y='adfs')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Making features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from scipy.stats import entropy\n",
    "from scipy import stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "N_BARS = 64000\n",
    "WINDOW_LONG = 100\n",
    "WINDOW_SHORT = 50\n",
    "HORIZON = 25\n",
    "T = 0.01\n",
    "H = 0.05"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-0.04359708998044693\n",
      "(30474097.664683025, 0.0)\n",
      "(0.727247953414917, 0.0)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda2/lib/python2.7/site-packages/scipy/stats/morestats.py:1310: UserWarning: p-value may not be accurate for N > 5000.\n",
      "  warnings.warn(\"p-value may not be accurate for N > 5000.\")\n"
     ]
    }
   ],
   "source": [
    "print pd.Series.autocorr(np.clip(tick_bars.close.pct_change(), -H, H).dropna())\n",
    "print stats.jarque_bera(np.clip(tick_bars.close.pct_change(), -H, H).dropna())\n",
    "print stats.shapiro(np.clip(tick_bars.close.pct_change(), -H, H).dropna())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "tick_bars['pct_change'] = np.clip(tick_bars.close.pct_change(), -H, H)\n",
    "tick_bars['pct_change_frac'] = np.clip(fast_fracdiff(np.log(tick_bars.close.values), d=0.5), 0, 0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['pct_change_frac']\n"
     ]
    }
   ],
   "source": [
    "FEATURES = ['pct_change_frac']\n",
    "print FEATURES"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def make_features_from_window(X_train_b, X_val, X_test, features):   \n",
    "    \n",
    "    X_train_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_train_b]).reshape((len(X_train_b), WINDOW_LONG, 1))\n",
    "    X_val_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_val]).reshape((len(X_val), WINDOW_LONG, 1))\n",
    "    X_test_normts = np.array([(x.close - x.close.iloc[0]) / np.std(x.close) for x in X_test]).reshape((len(X_test), WINDOW_LONG, 1))\n",
    "    \n",
    "    X_train_normv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_train_b]).reshape((len(X_train_b), WINDOW_LONG, 1))\n",
    "    X_val_normvv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_val]).reshape((len(X_val), WINDOW_LONG, 1))\n",
    "    X_test_normv = np.array([(x.volume - x.volume.iloc[0]) / np.std(x.volume) for x in X_test]).reshape((len(X_test), WINDOW_LONG, 1))\n",
    "  \n",
    "    X_train = np.array([x[features].fillna(0.).values.tolist() for x in X_train_b]) \n",
    "    X_val = np.array([x[features].fillna(0.).values.tolist() for x in X_val])\n",
    "    X_test = np.array([x[features].fillna(0.).values.tolist() for x in X_test])\n",
    "\n",
    "    X_train = np.concatenate((X_train, X_train_normts, X_train_normv), axis = -1)\n",
    "    X_val = np.concatenate((X_val, X_val_normts, X_val_normvv), axis = -1)\n",
    "    X_test = np.concatenate((X_test, X_test_normts, X_test_normv), axis = -1)\n",
    "    \n",
    "    return X_train, X_val, X_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_class_weights(y):\n",
    "    y = [np.argmax(x) for x in y]\n",
    "    counter = Counter(y)\n",
    "    majority = max(counter.values())\n",
    "    return  {cls: round(float(majority)/float(count), 2) for cls, count in counter.items()}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fixed horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X, labels = [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    \n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "#     window = tick_bars.iloc[i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    X.append(window)\n",
    "    if ret > T:\n",
    "        labels.append(1)\n",
    "    elif ret < -T:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz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nP2\nVVUvDGY/z+gc0/S6v3DUug8sQk9j9TWwBbhmWFjC/TWX2fpekn11sh9WmvFrO2p0lud+Rsf7AbYC\ni/VOZGfb3jjb7Y51tj+Q08f5rwBmvLJhKfpKsmr6sEySM4H3AU9Men+1n92XGR2PveuoZYu5v8b5\nmpdhv1cC97X9sxPYktHVTOcB64CvHkcv8+orybuB/wB8oKoODeoz/kyXsa+zB7MfAJ5s07uBS1p/\nq4BL+PF30EvaV+vtnYxO8P7RoLaU+2suO4Gr21VLG4GX24ufpdlXi3m2/US6AX+H0bG3V4Dngd2t\n/lPArsG4y4FvMkr+Twzq72D0j3cK+M/AqYvU19uAe4H9wFeAM1p9A/D5wbi1jF4RvOmo9e8DHmP0\nR+53gZ9crr6Av9Ye++vtftuJsL+AXwL+FHhkcDt/KfbXTL8vjA5TfaBNv7k9/6m2P94xWPcTbb2n\ngMsW+fd9rr6+0v4dTO+fnXP9TJepr38NPN4e/37gnYN1/0Hbj1PAR5azrzb/L4FPH7Xeku0vRi8E\nn2u/ywcYnRv6VeBX2/Iw+k/Rnm6PvWGw7qLvKz8hLUnqnOyHlSRJMzAcJEkdw0GS1DEcJEkdw0GS\n1DEcJEkdw0GS1DEcJEmd/w8bM79CUvwezgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = labels[:int(len(X) * 0.5)], labels[int(len(X) * 0.6):int(len(X) * 0.7)], labels[int(len(X) * 0.8):]\n",
    "\n",
    "lbr = LabelBinarizer()\n",
    "Y_train = lbr.fit_transform(Y_train)\n",
    "Y_val = lbr.transform(Y_val)\n",
    "Y_test = lbr.transform(Y_test)\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_1 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_1 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 5s 158us/step - loss: 4.2498 - acc: 0.3177 - val_loss: 1.3153 - val_acc: 0.2951\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 5s 166us/step - loss: 4.1291 - acc: 0.3158 - val_loss: 1.3417 - val_acc: 0.3374\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 5s 157us/step - loss: 4.2157 - acc: 0.3238 - val_loss: 1.6448 - val_acc: 0.2894\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 6s 173us/step - loss: 4.2682 - acc: 0.3231 - val_loss: 2.0274 - val_acc: 0.2438\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 8s 248us/step - loss: 4.1309 - acc: 0.3288 - val_loss: 1.3703 - val_acc: 0.4897\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 5s 169us/step - loss: 4.1875 - acc: 0.3230 - val_loss: 1.3931 - val_acc: 0.2587\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.02      0.30      0.04       211\n",
      "           1       0.92      0.30      0.45      5934\n",
      "           2       0.04      0.26      0.06       245\n",
      "\n",
      "   micro avg       0.30      0.30      0.30      6390\n",
      "   macro avg       0.33      0.28      0.19      6390\n",
      "weighted avg       0.86      0.30      0.42      6390\n",
      "\n",
      "[[  63   68   80]\n",
      " [2606 1760 1568]\n",
      " [ 101   81   63]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHd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ISEYmUAkBEJFIKABGRSCkAREQipQAQ\nEYmUAkBEJFL6PwARqd+S32Z2eZc1fAPg1q1b079/fw4cOMA555xDcXExJ5988nGt7o033uB3v/sd\nL774IgsXLmTNmjVMnTq1zr47d+7kL3/5Cz/96U/TWkeqdy3t2LEje/bsqXf68a7/RGgPQESalfbt\n21NWVsbq1atp164dDz/88GHT3Z1Dhw6lvdyxY8fW++YPiTfghx56KO3lZkpTrF8BICLN1qWXXkpF\nRQUbN27k7LPP5qabbuL8889n06ZNLFq0iCFDhpCXl8c111xT++n6lVdeoV+/fuTl5fHcc8/VLuux\nxx5jypQpAGzevJmrr76aAQMGMGDAAN5++22mTp3K+vXrGThwIL/4xS8AuO+++7jgggv41re+xfTp\n02uXde+993LWWWdxySWXsG7dujpr/+ijjxgyZAj9+/fn17/+dW37nj17GDZsGHl5efTv358XXkh8\nlcqR66+vXybpEJCINEsHDhzg5ZdfZtSoUQCUl5dTXFzM4MGD2bp1K/fccw+vvfYaHTp0YObMmfzh\nD3/gl7/8JT/60Y9YvHgxZ555Jtddd12dy77tttv47ne/y4IFCzh48CB79uxhxowZrF69uvYLaRYt\nWkR5eTnLly/H3Rk7dixvvvkmHTp0YN68eZSVlXHgwAHy8vL49re/fdQ6br/9dn7yk59w0003MXv2\n7Nr2nJwcFixYwNe+9jW2bt3K4MGDGTt27FHrP3DgQJ39MvmdzQoAEWlW9u7dW3sf/0svvZSCggL+\n8Y9/cMYZZzB48GAAli5dypo1a2pv6/zFF18wZMgQPvjgA/r06UPfvn0B+OEPf1jn3UEXL17M448/\nDiTOOZx66qns2LHjsD6LFi1i0aJFDBo0CEh8ci8vL2f37t1cffXVteclxo4dW+fzeOutt3j22WeB\nxG2n77jjDiBxCOvOO+/kzTffpFWrVlRVVbF58+aj5q+vXya+5ayGAkBEmpWacwBH6tChQ+2wu3P5\n5Zfz1FNPHdbnWN/tmy53Z9q0afz4xz8+rP2BBx5IeRl1fVp/8sknqa6uZuXKlbRt25bevXuzb9++\n4+53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q1i+1lZieTeBN9Nqk5K9vLEoenBwHLjpiUldfYV/orIZsrM/shkA98N6n5DHev\nMrNvAIvN7D13X5+lkv4KPOXu+83sxyT2nr6fpXWnYgLwjLsfTGpryu3VrJnZZSQC4JKk5kvC9jod\nKDGzD8In5Gx4h8Tva4+ZjQaeB/pmad2puBJ4y92T9xYafXuZWUcSofMf7v7PTC47VS1xD6DB20kk\n9zGzNsCpwLYU523MujCz4cCvgLHuvr+m3d2rws8NwBskPhVkpS5335ZUyyPAt1OdtzHrSjKBI3bP\nG3F7paK+2htze6XEzL5F4nc4zt1rvxQ7aXttARaQuUOfDXL3f7r7njD8EtDWzLrSDLZXcKzXV6Ns\nLzNrS+LN/0l3f66OLtl5jTXGSY7GfJDYa9lA4pBAzYmj847ocyuHnwSeH4bP4/CTwBvI3EngVOoa\nROKkV98j2jsDJ4XhrkA5GToZlmJd3ZOGrwaW+v8/4fRRqK9zGD4tW3WFfv1InJCzbGyvpHX0pv6T\nmmM4/ATd8sbeXinW9V9InNe6+Ij2DsApScNvk7gpY7bq+nrN74/EG+knYdul9BporLrC9FNJnCfo\nkK3tFZ7748ADx+iTlddYxjZ0Nh8kzpB/SOLN9Feh7S4Sn6oBcoD/E/4YlgPfSJr3V2G+dcAVWa7r\nNWAzUBYeC0P7xcB74Q/gPaAgy3X9Fng/rH8J0C9p3pvDdqwAJmezrjD+G2DGEfM19vZ6CvgU+JLE\nMdYC4N+AfwvTjcQXG60P68/P0vZqqK5HgB1Jr6/S0P6NsK3eDb/nX2W5rilJr6+lJAVUXa+BbNUV\n+kwicWFI8nyNvb0uIXGOYVXS72p0U7zG9J/AIiKRaonnAEREJAMUACIikVIAiIhESgEgIhIpBYCI\nSKQUACIikVIAiIhESgEgIhKp/wdj1v9vhmNSMAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.07      0.38      0.11       899\n",
      "           1       0.89      0.29      0.44     11116\n",
      "           2       0.07      0.36      0.12       765\n",
      "\n",
      "   micro avg       0.30      0.30      0.30     12780\n",
      "   macro avg       0.34      0.34      0.22     12780\n",
      "weighted avg       0.78      0.30      0.40     12780\n",
      "\n",
      "[[ 346  189  364]\n",
      " [4612 3222 3282]\n",
      " [ 286  207  272]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGn5JREFUeJzt3X90FeW97/H3twEMP1QQouUCGupB\nUQmEGC0UtbWgKFxF19UKtYo2Fo/I0eNte4W269Llj1Vd2qrUiodVU+PRil5/olcrqGHZq+VXaJTf\nElAkLNEAQrUCCnzvH/sJZ5MnITvZyd4JfF5r7ZWZZ56Z+TLZ5JOZZ/bE3B0REZFk38h2ASIi0vYo\nHEREJKJwEBGRiMJBREQiCgcREYkoHEREJKJwEBGRiMJBREQiCgcREYl0yHYBzdWrVy/Pz8/Pdhki\nIu1GRUXFFnfPS6Vvuw2H/Px8lixZku0yRETaDTPbkGpfXVYSEZGIwkFERCIKBxERibTbMQcRyZyv\nv/6a6upqdu3ale1SJAW5ubn07duXjh07NnsbCgcRaVR1dTVHHnkk+fn5mFm2y5GDcHe2bt1KdXU1\n/fv3b/Z2dFlJRBq1a9cuevbsqWBoB8yMnj17pn2Wp3AQkZQoGNqPlvheKRxERCSiMQcRabL75r3f\notu75byTDrp869atjBw5EoDNmzeTk5NDXl7ig76LFi2iU6dOKe2ntLSUMWPG8M1vfvOg/aqqqrjs\nssuorKxssM/69etZtGgR48ePT2nf7Y3CQQ5ZLf0DrK1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OV\nlZUsX76cTp06HfDkVEg8SmPfvn1N3u7FF1/cYDBA4ofzQw891OTttpRs7V/hICLtztlnn01VVRUf\nfvghJ598MldffTWDBg1i48aNzJ07l+HDh1NUVMTll1++/7fyv/zlLwwcOJCioiKee+65/dt69NFH\nmTJlCgCffPIJl156KUOGDGHIkCG88847TJ06lXXr1lFYWMjPf/5zAO655x7OOOMMBg8ezPTp0/dv\n68477+Skk07irLPOYs2aNfXW/sEHHzB8+HAKCgr41a9+tb/9iy++YOTIkRQVFVFQUMCLL74IEO2/\noX4trdFwMLNSM/vUzJYntR1jZvPMbG342iO0m5nNMLMqM3vPzIqS1pkY+q81s4lJ7aeb2bKwzgzT\nH6oVkYPYs2cPr776KgUFBQCsXbuWyZMns2LFCrp27codd9zB66+/ztKlSykuLuZ3v/sdu3bt4ic/\n+QkvvfQSFRUVbN68ud5t33TTTXz3u9/l3XffZenSpZx22mncddddnHjiiVRWVnLPPfcwd+5c1q5d\ny6JFi6isrKSiooK33nqLiooKZs+eTWVlJa+88gqLFy+udx8333wzN9xwA8uWLaN3797723Nzc3n+\n+edZunQp5eXl/PSnP8Xdo/031K+lpXLm8ChwQZ22qcAb7j4AeCPMA1wIDAivScBMSIQJMB34NnAm\nML02UEKfnyStV3dfIiLs3LmTwsJCiouLOf744ykpKQHghBNOYNiwYQAsWLCAlStXMmLECAoLCykr\nK2PDhg2sXr2a/v37M2DAAMyMH/3oR/Xu48033+SGG24AEmMcRx99dNRn7ty5zJ07l6FDh1JUVMTq\n1atZu3Ytf/3rX7n00kvp0qULRx11FBdffHG9+3j77beZMGECkHg0eC135xe/+AWDBw9m1KhRbNq0\niU8++SRaP9V+6Wp0QNrd3zKz/DrN44DvhekyYD5wa2h/zBMxtsDMuptZ79B3nrtvAzCzecAFZjYf\nOMrdF4T2x4BLgFfT+UeJyKGndsyhrq5du+6fdnfOO+88nnzyyQP6HOxvQTeVuzNt2jSuv/76A9rv\nv//+lLdR3wWSJ554gpqaGioqKujYsSP5+fns2r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ssQl76HAwjqLMvYeazO3sgqY2Y+A\nYuC7Sc0nuPsmM/sW8KaZLXP3dRkq6SXgSXffbWbXkzjr+n6G9p2K8cAz7r43qS2bx6tNM7NzSYTD\nWUnNZ4XjdSwwz8xWh9+sM2Epie/XF2Y2BngBGJChfafiIuBtd08+y2j142Vm3UgE0r+7+z9acttN\ncSidOaTyCI79fcysA3A0sDXFdVuzLsxsFPBL4GJ3313b7u6bwtf1wHwSv01kpC5335pUyx+B01Nd\ntzXrSjKeOqf8rXi8UtFQ7a15vFJiZoNJfA/HufvW2vak4/Up8Dwtdzm1Ue7+D3f/Iky/AnQ0s160\ngeMVHOz91SrHy8w6kgiGJ9z9uXq6ZO491hoDK9l4kTgLWk/iMkPtINZpdfrcyIED0k+H6dM4cEB6\nPS03IJ1KXUNJDMANqNPeAzgiTPcC1tJCA3Mp1tU7afpSYIH/1+DXB6G+HmH6mEzVFfoNJDE4aJk4\nXkn7yKfhAdaxHDhYuKi1j1eKdR1PYhztO3XauwJHJk2/Q+IBmJmq65u13z8SP2Q/CscupfdAa9UV\nlh9NYlyia6aOV/i3Pwbcf5A+GXuPtdjBbgsvEiP575P4QfvL0HYbid/GAXKB/xP+oywCvpW07i/D\nemuACzNc1+vAJ0BleM0J7d8BloX/HMuAkgzX9RtgRdh/OTAwad0fh+NYBVybybrC/K+Bu+qs19rH\n60ngY+BrEtd0S4B/Bf41LDcSf7RqXdh/cYaOV2N1/RH4LOn9tSS0fyscq3fD9/mXGa5rStL7awFJ\n4VXfeyBTdYU+15C4SSV5vdY+XmeRGNN4L+l7NSZb7zF9QlpERCKH0piDiIi0EIWDiIhEFA4iIhJR\nOIiISEThICIiEYWDiIhEFA4iIhJROIiISOT/Ax8xqcHZSfsCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.22662833, 0.42735487, 0.3460168 ],\n",
       "       [0.02252634, 0.31241223, 0.6650614 ],\n",
       "       [0.31027994, 0.28352553, 0.40619454],\n",
       "       ...,\n",
       "       [0.3319831 , 0.39908785, 0.26892897],\n",
       "       [0.4245464 , 0.23618537, 0.3392682 ],\n",
       "       [0.5815889 , 0.18120623, 0.2372049 ]], dtype=float32)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pred"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Volatility horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X, labels = [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    X.append(window)\n",
    "    if ret > Ti:\n",
    "        labels.append(1)\n",
    "    elif ret < -Ti:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAE0pJREFUeJzt3X+s3fV93/Hnq3ah3bIMEzyPAolJ\n665zO82hDkHLtOZHZQx/xESjmZEaTOrWaQNTq3VSSPMHUVK0ZFIbCS2lpcXDbG0II43wNKeuQ4ii\nSjWx01LAMOIbkgh7DnYxIZ2ikULe++N8bvuNP/f6Xt9f54KfD+nofM/7++t9Pufi1znf7/ccUlVI\nkjT0A+NuQJK0/BgOkqSO4SBJ6hgOkqSO4SBJ6hgOkqSO4SBJ6hgOkqSO4SBJ6qwcdwNzdcEFF9Ta\ntWvH3YYkvax8+ctf/uuqWj3Tci/bcFi7di0HDx4cdxuS9LKS5BuzWc7DSpKkjuEgSeoYDpKkjuEg\nSeoYDpKkjuEgSeoYDpKkjuEgSeoYDpKkzsv2G9KStP2uA+NuYcndecMbl2Q/fnKQJHUMB0lSx3CQ\nJHUMB0lSx3CQJHVmDIcklyR5MMnjSQ4l+dVW/1CSo0kebrerB+t8IMlEkieTXDmob261iSQ3D+qX\nJnmo1T+V5JyFfqKSp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P1ytRkp8HNgI/Myh3r2lVfXXqLSy4/wl8\nsqpeSPJeRp+63rZE+56NrcB9VfXSoDbO8VoyL+twqKqfnecmpvvZjmcZfWRb2d79TflzHnPpK8kz\nSS6sqmPtH7Pjp9nUu4DPVNXfDrY9+S76hST/FfiPS9lXVR1t908l+QLwBuDTjHm8krwa+F+M3hjs\nH2x7zuM1hdn8zMvkMkeSrAT+MaO/p1n9RMwi9kWSn2UUuD9TVS9M1qd5TRfiH7sZ+6qqZwcP/4DR\nOabJdd9yyrpfWICeZtXXwFbgxmFhEcdrJtP1vShjdbYfVpryZztqdJbnQUbH+wG2AQv1SWR3295s\nttsd62z/QE4e578GmPLKhsXoK8mqycMySS4A3gw8Pu7xaq/dZxgdj73vlHkLOV6z+ZmXYb/XAp9v\n47Mb2JrR1UyXAuuAL82jlzPqK8kbgN8D3lFVxwf1KV/TJezrwsHDdwBPtOm9wKbW3ypgE9//CXpR\n+2q9/QSjE7x/Pqgt5njNZDdwfbtq6Qrg+fbmZ3HGaiHPti+nG/BORsfeXgCeAfa2+o8AewbLXQ18\nhVHyf3BQfz2j/3gngP8BnLtAfb0GeAA4DHwOOL/VNwJ/MFhuLaN3BD9wyvqfBx5l9I/cfwdetVR9\nAf+q7fuv2v325TBewM8Dfws8PLhtWIzxmurvhdFhqne06R9qz3+ijcfrB+t+sK33JHDVAv+9z9TX\n59p/B5Pjs3um13SJ+vpPwKG2/weBnxis+wttHCeA9yxlX+3xh4CPnrLeoo0XozeCx9rf8hFG54Z+\nGfjlNj+M/qdoX2373jhYd8HHym9IS5I6Z/thJUnSFAwHSVLHcJAkdQwHSVLHcJAkdQwHSVLHcJAk\ndQwHSVLn/wMChZuz54nZiQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = labels[:int(len(X) * 0.5)], labels[int(len(X) * 0.6):int(len(X) * 0.7)], labels[int(len(X) * 0.8):]\n",
    "\n",
    "lbr = LabelBinarizer()\n",
    "Y_train = lbr.fit_transform(Y_train)\n",
    "Y_val = lbr.transform(Y_val)\n",
    "Y_test = lbr.transform(Y_test)\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_2 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_2 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 11s 342us/step - loss: 1.9417 - acc: 0.3350 - val_loss: 1.3366 - val_acc: 0.3812\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 6s 188us/step - loss: 1.9176 - acc: 0.3333 - val_loss: 1.6338 - val_acc: 0.3563\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 8s 241us/step - loss: 1.9315 - acc: 0.3355 - val_loss: 1.2706 - val_acc: 0.3557\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 9s 291us/step - loss: 1.9169 - acc: 0.3336 - val_loss: 1.4230 - val_acc: 0.3473\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 8s 259us/step - loss: 1.9471 - acc: 0.3320 - val_loss: 1.7356 - val_acc: 0.2919\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 8s 254us/step - loss: 1.9141 - acc: 0.3372 - val_loss: 1.2237 - val_acc: 0.3174\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 7s 232us/step - loss: 1.9164 - acc: 0.3354 - val_loss: 1.2794 - val_acc: 0.3324\n",
      "Epoch 8/100\n",
      "31950/31950 [==============================] - 6s 194us/step - loss: 1.8991 - acc: 0.3338 - val_loss: 1.2609 - val_acc: 0.3196\n",
      "Epoch 9/100\n",
      "31950/31950 [==============================] - 6s 187us/step - loss: 1.8992 - acc: 0.3362 - val_loss: 1.2335 - val_acc: 0.3305\n",
      "Epoch 10/100\n",
      "31950/31950 [==============================] - 6s 186us/step - loss: 1.8802 - acc: 0.3382 - val_loss: 1.3925 - val_acc: 0.3285\n",
      "Epoch 11/100\n",
      "31950/31950 [==============================] - 8s 245us/step - loss: 1.9059 - acc: 0.3326 - val_loss: 1.2916 - val_acc: 0.3377\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.31      0.34      0.33      2095\n",
      "           1       0.23      0.33      0.27      1518\n",
      "           2       0.41      0.29      0.34      2777\n",
      "\n",
      "   micro avg       0.32      0.32      0.32      6390\n",
      "   macro avg       0.32      0.32      0.31      6390\n",
      "weighted avg       0.34      0.32      0.32      6390\n",
      "\n",
      "[[ 714  708  673]\n",
      " [ 536  496  486]\n",
      " [1045  914  818]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGaxJREFUeJzt3X1wVdW9//H31xAMAqMIaPkJFepg\nEYmENFIo0upFRWCUMlcrtEVULN4iV9uf7Yi2c3F8mOKgtlItTu41FUcrcosoOlhBjcNckacw4Vkk\nIEooDwGVYgUU+N4/zkruISTkJDk5IazPa+ZM9ll77b2/Z+dwPtl77bMxd0dEROJzWnMXICIizUMB\nICISKQWAiEikFAAiIpFSAIiIREoBICISKQWAiEikFAAiIpFSAIiIRKpVcxdwIp06dfLu3bs3dxki\nIi1KSUnJHnfvXFe/kzoAunfvzooVK5q7DBGRFsXMPk6ln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mtMrM3zOzi0HZS7C8zO4PEh+icpOaM7C9L\nnJ7uByytNisj77GMXwYqYGY/BQqAHyQ1n+/u283sW8A7ZrbG3TdnqKTXgBfd/ZCZ3U7i6OlfMrTt\nVIwG/uruR5LamnN/ndTM7AoSAXBZUvNlYX+dAyw0sw/CX8iZsJLE7+sLMxsOvAL0zNC2U3Et8J67\nJx8tNPn+MrN2JELnF+7+j3SuO1Ut8QigzttJJPcxs1bAmcDeFJdtyrowsyuB3wDXufuhynZ33x5+\nbgHeJfFXQUbqcve9SbX8F/CdVJdtyrqSjKba4XkT7q9U1FZ7U+6vlJjZJSR+hyPdfW9le9L+2g3M\nJX2nPuvk7v9w9y/C9Hwg28w6cRLsr+BE768m2V9mlk3iw/8Fd3+5hi6ZeY81xSBHUz5IHLVsIXFK\noHLg6OJqfe7g2EHg2WH6Yo4dBN5C+gaBU6mrH4lBr57V2jsAp4fpTsAm0jQYlmJdXZKmRwFL/P8G\nnD4K9XUI02dnqq7QrxeJATnLxP5K2kZ3ah/UHMGxA3TLmnp/pVjXN0mMa32vWntboH3S9GISN2XM\nVF3fqPz9kfgg/STsu5TeA01VV5h/JolxgraZ2l/htT8H/OEEfTLyHkvbjs7kg8QI+YckPkx/E9oe\nIPFXNUAO8N/hH8My4FtJy/4mLLcRGJbhut4CdgGl4TEvtH8PWBP+AawBxme4rt8B68L2i4FeScve\nGvZjGXBLJusKz+8HplZbrqn314vADuBrEudYxwP/BvxbmG8k/mOjzWH7BRnaX3XV9V/AZ0nvrxWh\n/VthX60Kv+ffZLiuSUnvryUkBVRN74FM1RX63EziwpDk5Zp6f11GYoxhddLvanhzvMf0TWARkUi1\nxDEAERFJAwWAiEikFAAiIpFSAIiIREoBICISKQWAiEikFAAiIpFSAIiIROp/AeceH3JdoM+GAAAA\nAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.41      0.40      0.41      4922\n",
      "           1       0.23      0.32      0.27      2896\n",
      "           2       0.42      0.33      0.37      4962\n",
      "\n",
      "   micro avg       0.36      0.36      0.36     12780\n",
      "   macro avg       0.35      0.35      0.35     12780\n",
      "weighted avg       0.37      0.36      0.36     12780\n",
      "\n",
      "[[1965 1577 1380]\n",
      " [1045  940  911]\n",
      " [1757 1565 1640]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGilJREFUeJzt3X10VOW59/HvBUSDYEUhUpZQoRWL\nLxSIURPRtgoKyhF0HS1Yq4Cx9LRy9PSctmLb9dDHl1NY2qotqItVU+PRmnJUlLq0goLLdVTkxRMV\nQSQgalKFEF4KFdDA9fwxN3nGMCEzMDMJ3L/PWlnZ+9733vuancn8Zr/MHnN3REQkPh3augAREWkb\nCgARkUgpAEREIqUAEBGJlAJARCRSCgARkUgpAEREIqUAEBGJlAJARCRSndq6gP3p0aOH9+3bt63L\nEBE5pCxbtmyjuxe11q9dB0Dfvn1ZunRpW5chInJIMbMP0umnQ0AiIpFSAIiIREoBICISqbTOAZjZ\nOmAbsBtodPcSMzsO+DPQF1gHfMfdN5uZAfcClwCfAhPc/Y2wnPHAL8Nib3f3yuw9FGmPPv/8c2pr\na9m5c2dblyJpKCwspHfv3hQUFLR1KZIHmZwEPt/dNyaNTwFedPdpZjYljN8MXAz0Dz9nA/cDZ4fA\nmAqUAA4sM7O57r45C49D2qna2lqOPvpo+vbtS+K9gbRX7k5DQwO1tbX069evrcuRPDiYQ0BjgL3v\n4CuBy5LaH/aERUA3M+sFjADmu/um8KI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nLjP7AYm9pwvytO50jAMed/fdSW1tub3aNTM7n0QAnJvUfG7YXscD883s3fAOOR/eIPH32m5mlwBP\nAf3ztO50XAq84u7Jews5315m1pVE6Pybu/89m8tO16G4B9Dq7SSS+5hZJ+AYoCHNeXNZF2Y2HPgF\nMNrdd+1td/e68Hst8BKJdwV5qcvdG5Jq+QNwRrrz5rKuJONotnuew+2VjpZqz+X2SouZfYPE33CM\nuzfsbU/aXhuAOWTv0Ger3P3v7r49DD8LFJhZD9rB9gr29/zKyfYyswISL/6PuvuTKbrk5zmWi5Mc\nufwhsdeylsQhgb0njk5r1ucGvngSeHYYPo0vngReS/ZOAqdT1xASJ736N2s/FjgyDPcAVpOlk2Fp\n1tUrafhyYJH//xNO74f6jg3Dx+WrrtBvAIkTcpaP7ZW0jr60fFJzFF88Qbc419srzbq+QuK81jnN\n2rsARycNv0ripoz5quvLe/9+JF5IPwzbLq3nQK7qCtOPIXGeoEu+tld47A8D9+ynT16eY1nb0Pn8\nIXGG/D0SL6a/CG23knhXDVAI/Hf4Z1gMfDVp3l+E+VYBF+e5rheA9UB1+Jkb2s8B3g7/AG8D5Xmu\n69fAO2H9C4EBSfNeF7ZjDTAxn3WF8V8B05rNl+vt9RjwMfA5iWOs5cC/AP8SphuJLzZaE9Zfkqft\n1VpdfwA2Jz2/lob2r4Zt9Wb4O/8iz3VNTnp+LSIpoFI9B/JVV+gzgcSFIcnz5Xp7nUviHMNbSX+r\nS9riOaZPAouIROpQPAcgIiJZoAAQEYmUAkBEJFIKABGRSCkAREQipQAQEYmUAkBEJFIKABGRSP0/\nOMF2yB1vrHUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0: 1.23, 1: 1.82, 2: 1.0}\n",
      "[-1  0  1]\n"
     ]
    }
   ],
   "source": [
    "print get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "print lbr.classes_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Meta labeling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_meta_barier(future_window, last_close, min_ret, tp, sl, vertical_zero = False):\n",
    "    '''\n",
    "        XXX\n",
    "    '''\n",
    "    if vertical_zero:\n",
    "        min_ret_situation = [0, 0, 0]\n",
    "    else:\n",
    "        min_ret_situation = [0, 0]\n",
    "        \n",
    "        \n",
    "    differences = np.array([(fc - last_close) / last_close for fc in future_window])\n",
    "    \n",
    "    # Are there gonna be fluctuations within min_ret???\n",
    "    min_ret_ups = np.where((differences >= min_ret) == True)[0]\n",
    "    min_ret_downs = np.where((differences < -min_ret) == True)[0]\n",
    "  \n",
    "    if (len(min_ret_ups) == 0) and (len(min_ret_downs) == 0):\n",
    "        if vertical_zero:\n",
    "            min_ret_situation[2] = 1\n",
    "        else:\n",
    "            if differences[-1] > 0:\n",
    "                min_ret_situation[0] = 1\n",
    "            else:\n",
    "                min_ret_situation[1] = 1            \n",
    "    else:\n",
    "        if len(min_ret_ups) == 0: min_ret_ups = [np.inf]\n",
    "        if len(min_ret_downs) == 0: min_ret_downs = [np.inf]\n",
    "        if min_ret_ups[0] > min_ret_downs[0]:\n",
    "            min_ret_situation[0] = 1\n",
    "        else:\n",
    "            min_ret_situation[1] = 1\n",
    "        \n",
    "    #  Take profit and stop losses indices\n",
    "    take_profit = np.where((differences >= tp) == True)[0]\n",
    "    stop_loss = np.where((differences < sl) == True)[0]\n",
    "    \n",
    "    # Fluctuation directions coincide with take profit / stop loss actions?\n",
    "    if min_ret_situation[0] == 1 and len(take_profit) != 0:\n",
    "        take_action = 1\n",
    "    elif min_ret_situation[1] == 1 and len(stop_loss) != 0:\n",
    "        take_action = 1\n",
    "    else:\n",
    "        take_action = 0.\n",
    "    \n",
    "    return min_ret_situation, take_action"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TP = T\n",
    "SL = -T\n",
    "\n",
    "X, Y, Y2 = [], [], []\n",
    "for i in range(WINDOW_LONG, N_BARS, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW_LONG:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future_window = tick_bars.close[i:i+HORIZON]\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    min_ret_situation, take_action = get_meta_barier(future_window, now, Ti, TP, SL, True)\n",
    "    X.append(window)\n",
    "    Y.append(min_ret_situation)\n",
    "    Y2.append(take_action)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFHlJREFUeJzt3X+w3XWd3/Hna8MPXXUlyF3KQDC4\nZscJOxUwg6zrtAgVAp1tcGqdMO0SbbpxK3R03eksrjPFqkz1j106TJUOu2QMHWugqCV1YtkU6Thb\nJ0BQBAILXAOWZBCyhB8yTrHQd/84n7jHfO7NPbk/zg3k+Zg5c7/n/f18v+d9vufkvu73xzlJVSFJ\n0rBfWewGJEmHH8NBktQxHCRJHcNBktQxHCRJHcNBktQxHCRJHcNBktQxHCRJnaMWu4HZOuGEE2r5\n8uWL3YYkvarcc889f1NVEzONe9WGw/Lly9mxY8dityFJrypJfjzKOA8rSZI6hoMkqWM4SJI6hoMk\nqWM4SJI6hoMkqWM4SJI6hoMkqWM4SJI6r9pPSEszuWbbI4vdwtj94ft/c7Fb0GuEew6SpI7hIEnq\nGA6SpI7hIEnqGA6SpI7hIEnqGA6SpI7hIEnqGA6SpM6M4ZDkdUnuSvLDJDuT/NtWPy3JnUkmk9yU\n5JhWP7bdn2zzlw+t61Ot/nCSC4fqq1ttMsmV8/80JUmHYpQ9h5eA86rqncAZwOok5wBfBK6pqrcD\nzwLr2/j1wLOtfk0bR5KVwFrgdGA18OUkS5IsAb4EXASsBC5tYyVJi2TGcKiBF9vdo9utgPOAW1p9\nE3BJm17T7tPmn58krb65ql6qqseASeDsdpusql1V9XNgcxsrSVokI51zaH/h3ws8DWwDfgQ8V1Uv\ntyG7gZPb9MnAEwBt/vPAW4brBywzXV2StEhG+lbWqnoFOCPJccA3gXcsaFfTSLIB2ABw6qmnzno9\nflun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[
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist([np.argmax(x) for x in Y], alpha = 0.5, bins = 5)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = Y[:int(len(X) * 0.5)], Y[int(len(X) * 0.6):int(len(X) * 0.7)], Y[int(len(X) * 0.8):]\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Y_train, Y_val, Y_test = np.array(Y_train), np.array(Y_val), np.array(Y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "main_input (InputLayer)      (None, 100, 3)            0         \n",
      "_________________________________________________________________\n",
      "flatten_3 (Flatten)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dropout_3 (Dropout)          (None, 300)               0         \n",
      "_________________________________________________________________\n",
      "dense_3 (Dense)              (None, 3)                 903       \n",
      "=================================================================\n",
      "Total params: 903\n",
      "Trainable params: 903\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Train on 31950 samples, validate on 6390 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 202us/step - loss: 3.2768 - acc: 0.3455 - val_loss: 1.6196 - val_acc: 0.3700\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 6s 200us/step - loss: 3.3883 - acc: 0.3420 - val_loss: 1.7184 - val_acc: 0.3343\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 6s 184us/step - loss: 3.2865 - acc: 0.3484 - val_loss: 1.4454 - val_acc: 0.3729\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 6s 194us/step - loss: 3.2960 - acc: 0.3483 - val_loss: 1.3963 - val_acc: 0.3820\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 6s 192us/step - loss: 3.3174 - acc: 0.3511 - val_loss: 2.4761 - val_acc: 0.3682\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 8s 246us/step - loss: 3.4705 - acc: 0.3580 - val_loss: 1.2709 - val_acc: 0.4131\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 8s 251us/step - loss: 3.5451 - acc: 0.3438 - val_loss: 1.1883 - val_acc: 0.3876\n",
      "Epoch 8/100\n",
      "31950/31950 [==============================] - 6s 197us/step - loss: 3.1714 - acc: 0.3500 - val_loss: 1.2146 - val_acc: 0.3934\n",
      "Epoch 9/100\n",
      "31950/31950 [==============================] - 7s 216us/step - loss: 3.3911 - acc: 0.3502 - val_loss: 1.5469 - val_acc: 0.3152\n",
      "Epoch 10/100\n",
      "31950/31950 [==============================] - 9s 272us/step - loss: 3.2959 - acc: 0.3533 - val_loss: 1.8945 - val_acc: 0.3474\n",
      "Epoch 11/100\n",
      "31950/31950 [==============================] - 7s 207us/step - loss: 3.3394 - acc: 0.3530 - val_loss: 1.6301 - val_acc: 0.3535\n",
      "Epoch 12/100\n",
      "31950/31950 [==============================] - 6s 184us/step - loss: 3.3092 - acc: 0.3507 - val_loss: 1.5052 - val_acc: 0.4050\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    output = Dense(3, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit(X_train, Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = (X_val, Y_val),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val)))\n",
    "                )\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.45      0.47      0.46      2865\n",
      "           1       0.51      0.33      0.40      3307\n",
      "           2       0.05      0.28      0.08       218\n",
      "\n",
      "   micro avg       0.39      0.39      0.39      6390\n",
      "   macro avg       0.33      0.36      0.31      6390\n",
      "weighted avg       0.47      0.39      0.41      6390\n",
      "\n",
      "[[1335  961  569]\n",
      " [1568 1081  658]\n",
      " [  72   85   61]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGyxJREFUeJzt3X+QFOW97/H3R36IglEENBwhQhIM\n/kCWdTUQJIlBBbECsa5GTKJ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u9iOC73/0u119//R7zli9fzhNPPMFdd93FI488wvTp\n0/dpG7/61a/o27cv999/Px999BHdunVrUbv2wGMAZrbfO/3003n44YfZvHkzkLta6G9/+xs1NTVE\nBOeddx7XXXcdL7zwAgCHHHII27Zt22M9PXv25KCDDuL5558H4IEHHqift3XrVnr37o0kZsyYQUQ0\nuK7G2rVHPgIws0btL1ccDRo0iKlTp3L66afz8ccf06lTJ+6++246dOjAxIkTiQgkcfPNNwNwySWX\ncOmll3LQQQftcfno7373Oy699FIOOOAAzjjjjPr65MmTOffcc6msrOTss8/mwAMPBGDIkCHs3LmT\nwYMHM3HixEbbtUfan9OroqIi/IUwtje+DLS4Vq1axbHHHttq67fia+h3JmlpRFQ0taxPAZmZZZQD\nwMwsoxwAZmYZ5QAwM8soB4CZWUY5AMzMMsp/B2BmjZv/i+Ku77RrmmzSoUMHBg0aRG1tLcceeywz\nZszg4IMP3qfN/fWvf+WXv/wlf/rTn5g9ezYrV65kypQpDbZ99913+f3vf8/ll1/erG0UetfSbt26\nsX379kbn7+v2W6LJIwBJXSQtkvSipJcl/Z9U7y9poaQqSQ9J6pzqB6bnVWl+v7x1XZPqqyWNaq0X\nZWbt10EHHcSyZctYsWIFnTt33uWOnZC7LcTHH3/c7PWOHTu20Q9/yH0A//a3v232eoulLbZfyCmg\nHcDXImIwUAaMljQUuBm4LSI+D7wDTEztJwLvpPptqR2SjgPGA8cDo4HfSupQzBdjZp8sI0aMoKqq\nivXr1/OFL3yBiy66iBNOOIE33niDuXPnMmzYMMrLyznvvPPq/3f95z//mYEDB1JeXs6jjz5av657\n772XyZMnA7Bx40bOOeccBg8ezODBg3nuueeYMmUKa9eupaysjB//+McA3HLLLZx88smceOKJTJ06\ntX5dN954I8cccwynnnoqq1evbrDvr732GsOGDWPQoEH8/Oc/r69v376dkSNHUl5ezqBBg3j88ccB\n9th+Y+2KqclTQJH7U+G645ZO6RHA14BvpfoM4FpgGjAuTQP8AbhTuS+uHAfMjIgdwGuSqoBTgOeL\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unAz4CxEbGjrh4RG9LPdcBfyf2voCT9iogteX35D+Ck\nQpdtzX7lGc9uh+etuL8K0VjfW3N/FUTSieR+h+MiYktdPW9/bQJmUbxTn02KiH9ExPY0PQfoJKkn\n+8H+Svb2/mqV/SWpE7kP/wci4tEGmpTmPdYagxyt+SB31LKO3CmBuoGj43drcwW7DgI/nKaPZ9dB\n4HUUbxC4kH4NITfoNWC3enfgwDTdE1hDkQbDCuxX77zpc4AF8d8DTq+l/nVP04eXql+p3UByA3Iq\nxf7K20Y/Gh/UPJtdB+gWtfb+KrBfnyE3rvWl3epdgUPypp8jd1PGUvXr03W/P3IfpH9L+66g90Br\n9SvNP5TcOEHXUu2v9NrvA369lzYleY8VbUeX8kFuhPxVch+mP0u168j9rxqgC/B/0z+GRcBn85b9\nWVpuNXBWifv1JLARWJYes1P9S8BL6R/AS8DEEvfrF8DLafvzgYF5y3437ccq4JJS9is9vxa4abfl\nWnt/PQi8CXxE7hzrROBfgX9N80Xui43Wpu1XlGh/NdWv/wDeyXt/LUn1z6Z99WL6Pf+sxP2anPf+\nWkBeQDX0HihVv1Kbi8ldGJK/XGvvr1PJjTEsz/tdjWmL95j/EtjMLKPa4xiAmZkVgQPAzCyjHABm\nZhnlADAzyygHgJlZRjkAzMwyygFgZpZRDgAzs4z6/1w8n/37vIUZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.49      0.46      0.48      6225\n",
      "           1       0.49      0.36      0.41      6189\n",
      "           2       0.03      0.19      0.05       366\n",
      "\n",
      "   micro avg       0.41      0.41      0.41     12780\n",
      "   macro avg       0.34      0.34      0.31     12780\n",
      "weighted avg       0.48      0.41      0.43     12780\n",
      "\n",
      "[[2889 2232 1104]\n",
      " [2767 2220 1202]\n",
      " [ 184  113   69]]\n"
     ]
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JFIKABGRSCkAREQipQAQEYnU/wcb7vLVlbgw1wAAAABJRU5ErkJg\ngg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict(X_val)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict(X_test)\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X_train, X_val, X_test = X[:int(len(X) * 0.5)], X[int(len(X) * 0.6):int(len(X) * 0.7)], X[int(len(X) * 0.8):]\n",
    "Y_train, Y_val, Y_test = Y2[:int(len(X) * 0.5)], Y2[int(len(X) * 0.6):int(len(X) * 0.7)], Y2[int(len(X) * 0.8):]\n",
    "\n",
    "X_train, X_val, X_test = make_features_from_window(X_train, X_val, X_test, FEATURES)\n",
    "P_train, P_val, P_test = model.predict(X_train), model.predict(X_val), model.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Y_train = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_train])\n",
    "Y_val = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_val])\n",
    "Y_test = np.array([[1, 0] if x == 1 else [0, 1] for x in Y_test])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "main_input (InputLayer)         (None, 100, 3)       0                                            \n",
      "__________________________________________________________________________________________________\n",
      "flatten_4 (Flatten)             (None, 300)          0           main_input[0][0]                 \n",
      "__________________________________________________________________________________________________\n",
      "dropout_4 (Dropout)             (None, 300)          0           flatten_4[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "meta (InputLayer)               (None, 3)            0                                            \n",
      "__________________________________________________________________________________________________\n",
      "concatenate_1 (Concatenate)     (None, 303)          0           dropout_4[0][0]                  \n",
      "                                                                 meta[0][0]                       \n",
      "__________________________________________________________________________________________________\n",
      "dense_4 (Dense)                 (None, 2)            608         concatenate_1[0][0]              \n",
      "==================================================================================================\n",
      "Total params: 608\n",
      "Trainable params: 608\n",
      "Non-trainable params: 0\n",
      "__________________________________________________________________________________________________\n",
      "Train on 31950 samples, validate on 12780 samples\n",
      "Epoch 1/100\n",
      "31950/31950 [==============================] - 6s 193us/step - loss: 2.9034 - acc: 0.4788 - val_loss: 1.0905 - val_acc: 0.5209\n",
      "Epoch 2/100\n",
      "31950/31950 [==============================] - 6s 194us/step - loss: 2.6902 - acc: 0.4894 - val_loss: 1.0154 - val_acc: 0.5297\n",
      "Epoch 3/100\n",
      "31950/31950 [==============================] - 6s 198us/step - loss: 2.8014 - acc: 0.4962 - val_loss: 0.7995 - val_acc: 0.6202\n",
      "Epoch 4/100\n",
      "31950/31950 [==============================] - 7s 207us/step - loss: 2.9782 - acc: 0.4863 - val_loss: 1.1041 - val_acc: 0.4821\n",
      "Epoch 5/100\n",
      "31950/31950 [==============================] - 6s 192us/step - loss: 2.7570 - acc: 0.4877 - val_loss: 0.9376 - val_acc: 0.5396\n",
      "Epoch 6/100\n",
      "31950/31950 [==============================] - 6s 188us/step - loss: 2.8829 - acc: 0.4860 - val_loss: 2.0553 - val_acc: 0.6032\n",
      "Epoch 7/100\n",
      "31950/31950 [==============================] - 6s 177us/step - loss: 2.8434 - acc: 0.4911 - val_loss: 1.2025 - val_acc: 0.4656\n",
      "Epoch 8/100\n",
      "31950/31950 [==============================] - 6s 190us/step - loss: 2.7781 - acc: 0.4955 - val_loss: 1.4456 - val_acc: 0.5119\n"
     ]
    }
   ],
   "source": [
    "def cnn(shape):\n",
    "    main_input = Input(shape=shape, name='main_input')\n",
    "    aux_input = Input((3, ), name='meta')\n",
    "    \n",
    "    x = Flatten()(main_input)\n",
    "    x = Dropout(0.25)(x)\n",
    "    x = concatenate([x, aux_input])\n",
    "    output = Dense(2, activation = \"softmax\")(x)\n",
    "    \n",
    "    final_model = Model(inputs=[main_input, aux_input], outputs=[output])\n",
    "    return final_model\n",
    "\n",
    "\n",
    "model = cnn((WINDOW_LONG, len(X_train[0][0]), ))\n",
    "model.summary()\n",
    "\n",
    "model.compile(optimizer=Adam(lr = 0.01),  \n",
    "                        loss=['categorical_crossentropy'], \n",
    "                        metrics = ['accuracy'])\n",
    "\n",
    "checkpointer = ModelCheckpoint(filepath=\"test.hdf5\", verbose=0, save_best_only=True)\n",
    "es = EarlyStopping(monitor='val_loss', patience=5)\n",
    "\n",
    "history = model.fit([X_train, P_train], Y_train, \n",
    "              epochs = 100, \n",
    "              batch_size = 16, \n",
    "              verbose=True, \n",
    "              validation_data = ([X_test, P_test], Y_test),\n",
    "              callbacks=[checkpointer, es],\n",
    "              shuffle=True, \n",
    "              class_weight = get_class_weights(np.concatenate((Y_train, Y_val))))\n",
    "\n",
    "model.load_weights(\"test.hdf5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.02      0.43      0.04       120\n",
      "           1       0.98      0.62      0.76      6270\n",
      "\n",
      "   micro avg       0.62      0.62      0.62      6390\n",
      "   macro avg       0.50      0.53      0.40      6390\n",
      "weighted avg       0.96      0.62      0.75      6390\n",
      "\n",
      "[[  52   68]\n",
      " [2361 3909]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGcJJREFUeJzt3X9wVeW97/H3V34YBCsK0TIEG05F\n0UMkxKjJUNpaFBBuQeeiYqugjaWjcvR6T1uxtzP0+mMOjFUrVfHk1tRYfyBXi1KvP0DBYa7Kz4qI\nIBIQJVQh/LxQAQ187x/7IbOBxOyQnb3ZPp/XTCZrfdez13oeg/nstdaTtc3dERGR+ByX7Q6IiEh2\nKABERCKlABARiZQCQEQkUgoAEZFIKQBERCKlABARiZQCQEQkUgoAEZFItc92B75O9+7dvbCwMNvd\nEBHJKUuXLt3i7vnNtTumA6CwsJAlS5ZkuxsiIjnFzD5JpZ0uAYmIREoBICISKQWAiEikjul7AI35\n6quvqK2tZe/evdnuiqQgLy+PgoICOnTokO2uiMhhci4AamtrOfHEEyksLMTMst0d+RruztatW6mt\nraV3797Z7o6IHCbnLgHt3buXbt266Zd/DjAzunXrprM1kWNUzgUAoF/+OUQ/K5FjV04GgIiItF7O\n3QM43ANzPkrr/m675Myv3b5161YGDx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07lzZ6ZPn86yZcuor6+npKSE884774hj3Hrrrdx4442MHTuWhx9+uKGel5fHzJkz+da3vsWWLVso\nKytj5MiRRxy/vr6+0Xb6HGCR3KAAOAp79uxpeI7/oEGDqKio4B//+Aff+c53KCsrA2DBggWsXLmy\n4bHOX375JeXl5Xz44Yf07t2bPn36AHDNNdc0+nTQuXPn8sQTTwCJew4nnXQS27cf+tik2bNnM3v2\nbAYMGAAk3rmvWbOGXbt2cfnllzfclxg5cmSj43jrrbd4/vnngcRjp2+//XYgcQnrN7/5DfPnz+e4\n445j48aNbNq06YjXN9UuHZ9yJiJtTwFwFA7eAzhc586dG5bdnUsuuYRnnjn0UUdf99m+LeXu3HHH\nHfziF784pP6HP/wh5X009m79qaeeoq6ujqVLl9KhQwcKCwvZu3fvUbcTkWOT7gG0kbKyMt566y1q\namoA+Oc//8lHH31E3759Wb9+fcOHtBweEAcNHjyYadOmAbB//3527tx5xGOfhw4dSlVVVcO9hY0b\nN7J582a+//3v88ILL7Bnzx527drF3/72t0aPMXDgQKZPnw4c+djpU089lQ4dOjBv3jw++eQToPHH\nTjfWTkRyQ+6fAaQwbTMb8vPzefzxx7n66qvZt28fAHfffTdnnnkmlZWVjBgxghNOOIFBgwY1+rkA\nDz74IOPHj+exxx6jXbt2TJs2jfLycgYOHEi/fv249NJLuffee1m1ahXl5eVAYhrnk08+SUlJCVdd\ndRX9+/fn1FNP5fzzz2+0jw8++CA/+clPmDJlCqNGjWqo//SnP+XHP/4xRUVFlJaW0rdvXwC6det2\nyPFvv/32RtuJSG5o9nHQ2aTHQX8z6GcmraXHQbdMOh8HLSIi30AKABGRSOVkABzLl63kUPpZiRy7\nci4A8vLy2Lp1q36x5AB3Z+vWreTl5WW7KyLSiJybBVRQUEBtbS36tLDckJeXR0FBQba7ISKNyLkA\n6NChA7179852N0REcl7OXQISEZH0UACIiERKASAiEikFgIhIpBQAIiKRUgCIiERKASAiEikFgIhI\npBQAIiKRSikAzGy9mb1vZsvMbEmonWJmc8xs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plsqYHfhWWD4J+EcG+5d27j4f2PY1TUYBT3jCAqCrmfVI\n1/FzPQBSebREQxt3rwd2At0y0ru20dLHaVSQeAeRy5odczg17uXu/yeTHWtDqfyczwTONLO3zGxB\neNJuLktlzL8DrjGzWhKzCf8tM13LmjZ9fM4x9ygISR8zuwYoBX6Q7b60JTM7DrgfuC7LXcm09iQu\nA/2QxFnefDMrcvcdWe1V27oaeNzd7zOzcuAvZtbP3Q9ku2O5KNfPAJp9tERyGzNrT+K0MZc/KCCV\nMWNmFwP/Axjp7vsy1Le20tyYTwT6AW+a2XoS10pn5fiN4FR+zrXALHf/yt0/Bj4iEQi5KpUxVwAz\nANz9HSCPxHOCvqlS+v/9aOV6AKTyaIlZwLiwPBqY6+HuSo5qdsxmNgD4TxK//HP9ujA0M2Z33+nu\n3d290N0LSdz3GOnuS7LT3bRI5d/2CyTe/WNm3UlcElqXyU6mWSpj/hQYDGBmZ5MIgLqM9jKzZgFj\nw2ygMmCnu3+Wrp3n9CUgb+LREmZ2J7DE3WcBj5E4TawhcbNlTPZ63HopjvleoAvwv8P97k/dfWTW\nOt1KKY75GyXFMb8GDDGzlcB+4FfunrNntymO+d+B/2Vmt5G4IXxdLr+hM7NnSIR493BfYxLQAcDd\nHyVxn2M4UAN8AVyf1uPn8H87ERFphVy/BCQiIkdJASAiEikFgIhIpBQAIiKRUgCIiERKASAiEikF\ngIhIpBQAIiKR+v9f+nMYdy6wrAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       0.03      0.43      0.06       360\n",
      "           1       0.97      0.63      0.76     12420\n",
      "\n",
      "   micro avg       0.62      0.62      0.62     12780\n",
      "   macro avg       0.50      0.53      0.41     12780\n",
      "weighted avg       0.95      0.62      0.74     12780\n",
      "\n",
      "[[ 154  206]\n",
      "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j7vXADiCvVarLvK/6CJJSEu882rNmxxwOt/u6\n+3+1ZmGHUSqv88nAyWb2ipktNbMxrVbd4ZHKmG8DLjezWhJ3Pf5z65SWNYf9kUNt5lZWaT1mdjlQ\nDHwv27UcTmZ2FHAvcGWWS2ltnUicWvp7EkeHS8xsiLtvz2pVh9elwCPufo+ZjQB+b2aD3X1ftgtr\nrzrykUMqj+Ro6GNmnUgcjrbXr4lL6REkZnYW8G/AWHff00q1HS7Njfk4YDDwspl9QOLc7Lx2flE6\nlde5Fpjn7l+6+/vAeyTCor1KZcylwBwAd38NyCXx3KWOKqV/7+noyOGQyiM55gGTwvR4YJGHqz3t\nULPjNbNhwP8mEQzt/Tw0NDNmd9/h7j3dvcDdC0hcZxnr7lXZKTcjUvl7/TSJowbMrCeJ00zrW7PI\nDEtlzB8BowHM7FQS4VDXqlW2rnnAxHDXUgmww90/zuQOOuxpJW/ikRxmdjtQ5e7zgNkkDj9rSFz8\nmZC9itOT4njvAo4F/jNcd//I3cdmreg0pTjmDiXFMc8HzjGzVcBe4Ofu3l6PiFMd878C/8fMbiZx\ncfrKdvxGDzN7nETA9wzXUaYBnQHc/WES11XOB2qAz4CrMl5DO/7zExGRw6Qjn1YSEZEWUjiIiEhE\n4SAiIhGFg4iIRBQOIiISUTiIiEhE4SAiIhGFg4iIRP4/M+zGPXIqGqcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pred = model.predict([X_val, P_val])\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_val],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_val], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "\n",
    "pred = model.predict([X_test, P_test])\n",
    "\n",
    "print classification_report([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "print confusion_matrix([np.argmax(y) for y in Y_test],\n",
    "                            [np.argmax(y) for y in pred])\n",
    "\n",
    "plt.plot()\n",
    "plt.hist([np.argmax(y) for y in Y_test], bins = 5, alpha = 0.5, label = 'Test data')\n",
    "plt.hist([np.argmax(y) for y in pred], bins = 5, alpha = 0.5, label = 'Predicted data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEadJREFUeJzt3X+sZGddx/H3B5aCP7At9Lpp9ocL\noaJEIzQ3tESjyKopi2FJxKZEYGlWN1EgKkZZ9Q/rjz9KjCIkBF0pujUKrVXshlaxKTSosdWtxQpU\n5FqL3bVlFyjrjwa1+vWPeUpm19295947c+fOc9+vZDLnPOeZOc9zZ/dzzjznx6SqkCT16ymzboAk\naboMeknqnEEvSZ0z6CWpcwa9JHXOoJekzhn0ktQ5g16SOjco6JNclOSWJH+f5IEkL0nyrCR3JPl0\ne7641U2SdyZZSnJ/ksun2wVJ0vlkyJWxSQ4Df1ZV70lyAfCVwM8AX6iq65McBC6uqrcm2QO8GdgD\nXAG8o6quON/7X3LJJbVr1641dkWSNpd77733c1W1sFy9ZYM+yYXAx4Dn1ljlJJ8CXlpVjyS5FLir\nqp6f5Dfa9PvOrHeudSwuLtbRo0cHdUySNJL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W\nCkeAfW361cCHqx3dmFPL9jnJi4DfYBTy8z5m+6Tz9ruqTlXVJVW1q6p2MTo28cqqOjqb5k7EkH/f\nf8Rob54klzAaynlwPRs5YUP6/M/AboAk38go6E+uayvX3xHg9e3smyuBU1X1yCTeeMMP3dQ5bqmQ\n5BeAo1V1BLiB0Ve7JUYHO66ZXYvXbmCffxn4auD323Hnf66qV86s0RMwsN9dGdjnDwHfk+STwP8A\nP1lVc/uNdWCffwL4zSQ/zujA7BvmfOeNJO9jtMG+pB17+DngaQBV9euMjkXsAZaAx4FrJ7buOf/b\nSZKWMQ9DN5KkNTDoJalzBr0kdc6gl6TOGfSS1DmDXpI6Z9BLUucMeknq3P8BLakrHGVGpn4AAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(pred, bins = 50)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: 14.8, 1: 1.0}"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_class_weights(np.concatenate((Y_train, Y_val)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
